﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace thinger.DelegateLambda
{
    public delegate T GenericDelegate<T>(T a, T b);
    class Program
    {
        
        static void Main(string[] args)
        {
            ActionAndFuncBase baseDelegate = new ActionAndFuncBase();
            baseDelegate.Test2();
            Console.WriteLine("*********************************");
            Console.Read();
        }

        static void Test()
        {
            GenericDelegate<int> delegate1 = Add;
            delegate1.Invoke(3, 4);
            GenericDelegate<double> delegate2 = Sub;
            delegate2.Invoke(10.9, 2.1);

            GenericDelegate<int> delegate3 = delegate (int a, int b) { return a + b; };
            GenericDelegate<double> delegate4 = delegate (double a, double b) { return a - b; };

            GenericDelegate<int> delegate5 = (int a, int b) => { return a + b; };
            GenericDelegate<double> delegate6 = (double a, double b) => { return a - b; };

            GenericDelegate<int> delegate7 = (a, b) => a + b;
            GenericDelegate<double> delegate8 = (a, b) => a - b;


        }

        static int Add(int a,int b)
        {
            return a + b;
        }

        static double Sub(double a,double b)
        {
            return a - b;
        }
    }
}
